﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using GD.ModelContest.Model;
using GD.ModelContest.Service;
using GD.ModelContest.Common;

namespace GD.ModelContest.Web.Admin
{
    public partial class ListCustomer : BaseCheckPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                DataBind_UserCollection(0);
            }
        }

        protected void DataBind_UserCollection(int recordcount)
        {
            if (recordcount == 0)
            {
                this.AspNetPager_FH.CurrentPageIndex = 1;
            }

            int count = recordcount;
            int pageIndex = this.AspNetPager_FH.CurrentPageIndex;
            int pageSize = this.AspNetPager_FH.PageSize;

            this.rpNewsCollection.DataSource = ServiceLocator.IUserService.GetUserCollection("", "", "", "", "", "", "", pageIndex, pageSize, ref count);
            this.rpNewsCollection.DataBind();
            this.AspNetPager_FH.RecordCount = count;
        }

        protected void rpNewsCollection_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                mc_user user = (mc_user)e.Item.DataItem;

                Label lblId = (Label)e.Item.FindControl("lblId");
                lblId.Text = user.userId.ToString();

                Label lblRealName = (Label)e.Item.FindControl("lblRealName");
                lblRealName.Text = user.name;

                Label lblSex = (Label)e.Item.FindControl("lblSex");
                lblSex.Text = user.sex;

                Label lblEmail = (Label)e.Item.FindControl("lblEmail");
                lblEmail.Text = user.email;
            }
        }

        protected void AspNetPager_FH_PageChanged(object sender, EventArgs e)
        {
            DataBind_UserCollection(this.AspNetPager_FH.RecordCount);
        }


    }
}
